from google.appengine.ext import webapp
from pyth.inventionmodels import *

class Purge(webapp.RequestHandler):
    def post(self):
        limit = self.request.get("limit")
        if not limit:
            limit = 10
        table = self.request.get('table')
        if not table:
            table = 'Workshop'
        exec('q = '+table+'.all()')
        if q.count() > 0:
            [db.delete(result) for result in q.fetch(int(limit))]
        else:
            self.response.out.write('no entries left for ' + table) 